package com.ymttest.database.mongo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.bson.types.ObjectId;

import com.google.gson.reflect.TypeToken;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor;
import com.ymatou.iapi.trading.operate.parameter.resp.AcceptOrderResult;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.database.MongoDBDriver;
import com.ymttest.utils.EnvSetup;

/**
 * SyncCommand
 * 
 *订单同步指令记录表
 */
public class SyncCommandWapper {
	MongoDBDriver mdd;

	public SyncCommandWapper() throws Exception {
		mdd = new MongoDBDriver(EnvSetup.getSystemUrl("set5_mongoip"), Integer.valueOf(EnvSetup
				.getSystemUrl("set5_mongoport")), "Order");
		mdd.selectCollection("SyncCommand");		
		mdd.auth("Orderuser", "123456");	
		}

	/**
	 * 根据条件查询一条订单同步指令结果记录
	 * 
	 * @param id
	 * @return BuyerSellerOrderStatisticsMongoBean
	 * @throws Exception
	 */
	public Map getSyncCommand(String cmdId) throws Exception {
		Map re = new HashMap();
		
		BasicDBObject queryObject=new BasicDBObject();
		
		queryObject.put("_id",new ObjectId(cmdId));
		DBCursor querycursor = mdd.getCollection().find(queryObject);
		
		while (querycursor.hasNext()) {
			re=querycursor.next().toMap();
			return re;
		}
		return null;
	}
	protected void close() throws Throwable {
		mdd.close();
	}
	
	public static void main(String args[])
	{
		try {
			Map map=new SyncCommandWapper().getSyncCommand("586f4b0aef2e88234a7479f0");
			
			Logger.debug("buyerSellerOrderStatisticsList:"+map);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
